package com.bjsxt.commu1;

/**
 * 消费者线程（实际是任务）
 */
public class ConsumeRunnable implements Runnable {

    private ProductFactory factory;

    public ConsumeRunnable() {
    }

    public ConsumeRunnable(ProductFactory factory) {
        this.factory = factory;
    }

    public ProductFactory getFactory() {
        return factory;
    }

    public void setFactory(ProductFactory factory) {
        this.factory = factory;
    }

    @Override
    public void run() {

        while (true) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //消费一件产品
            factory.consume();
        }
    }
}
